
import { getUnreadCount } from '@/api/error'

const state = {
  unreadCount: 0
}

const mutations = {

  SET_UNREAD_COUNT: (state, unreadCount) => {
    state.unreadCount = unreadCount
  }
}

const actions = {
  setUnreadCount({ commit }, queryVo) {
    return new Promise((resolve, reject) => {
      getUnreadCount(queryVo).then(response => {
        commit('SET_UNREAD_COUNT', response.data.unreadCount)

        resolve()
      }).catch(error => {
        reject(error)
      })
    })
  }

}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
